| <?xml version="1.0"?>
| <!DOCTYPE window SYSTEM "chrome://zotero-better-bibtex/locale/zotero-better-bibtex.dtd">
| <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
dialog(
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:html="http://www.w3.org/1999/xhtml"
    title='&better-bibtex_server-url.title;'
    onload='update();'
    buttons='accept'
    buttonlabelaccept='&better-bibtex_server-url.buttonlabelaccept;'
    buttonaccesskeyaccept='O'
  )
  dialogheader(title='&better-bibtex_server-url.title;')/
  script.
    function setURL(id, url) {
      const elt = document.getElementById(id);
      elt.value = url
      elt.setAttribute('style', `min-width: ${url.length / 2}em; color: blue;`)
      return elt.offsetWidth
    }

    function update() {
      const params = window.arguments[0];
      const ext = document.getElementById('formats').value

      document.getElementById('pull-export-long-available').hidden = !params.url.long

      window.resizeTo(Math.max(
        setURL('pull-export-short', params.url.short + ext),
        setURL('pull-export-long', params.url.long + ext)
      ), window.outerHeight)
    }
    window.addEventListener('load', function () {
      update()
    })
  groupbox(flex='1')
    vbox(flex='1')
      hbox(flex='1')
        label &better-bibtex_server-url_format;
        menulist#formats(oncommand='update()')
          menupopup
            menuitem(value='.biblatex' label='BibLaTeX')
            menuitem(value='.bibtex' label='BibTeX')
            menuitem(value='.yaml' label='CSL YAML')
            menuitem(value='.json' label='CSL JSON')
      description &better-bibtex_server-url_description;
      html:input#pull-export-short.plain(type='text' flex='1' readonly='true')/
      vbox#pull-export-long-available(flex='1')
        description &better-bibtex_server-url_or;
        html:input#pull-export-long.plain(type='text' flex='1' readonly='true')/
